 
#include "DXUT.h"
INT WINAPI wWinMain( HINSTANCE, HINSTANCE, LPWSTR, int );
 


class Demo:public IUpdateable,public IRenderable ,public IMsgProcessor, public ITerminate,public IInitialize

{
	virtual void OnUpdate( double fTime, float fElapsedTime ) 
	{
		
	}

	virtual void OnD3D9FrameRender( float fElapsedTime ) 
	{
		pGamera->DefaultHandle(fElapsedTime);
		DXUTGetD3D9Device()->SetRenderState(D3DRS_LIGHTING,FALSE);
		pGamera->ApplyCamera(DXUTGetD3D9Device());
		pMeshInstance->OnD3D9FrameRender(fElapsedTime);
		 
	}

	virtual LRESULT OnMsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam,bool* pbNoFurtherProcessing ) 
	{

		 return S_OK;
	}

	virtual void OnTerminate( void ) 
	{
		 
	}

	virtual HRESULT OnInitialize( void ) 
	{ 
		     Singleton<CGame>::Instance()->AddDeviceStateDeposit(Singleton<CGraphicsResourceManager>::Instance());
			Singleton<CGame>::Instance()->AddRenderDeposit(this);
			Singleton<CGame>::Instance()->AddMsgProcessorDeposit(this);
			Singleton<CGame>::Instance()->AddUpdateDeposit(this);


			pMesh=new CMesh(TEXT("dsfsdf"),TEXT("house.X"));
			Singleton<CGraphicsResourceManager>::Instance()->Add((void **)&pMesh);
			pMeshInstance=new CMeshInstance(pMesh);
			 pMeshInstance->SetPosition(D3DXVECTOR3(0.0f,0.0f,0.0f));
			 pMeshInstance->SetScale(D3DXVECTOR3(0.1f,0.1f,0.1f) );
			pGamera=new ICamera();
			pGamera->SetViewParams(&D3DXVECTOR3(0,0,-10),&D3DXVECTOR3(0,0,0));
			pGamera->SetProjParams(D3DX_PI/4,1,1.0f,100);
			return S_OK;
	}
private:
	CMesh * pMesh;
	CMeshInstance  * pMeshInstance;
	ICamera *  pGamera;

};
INT WINAPI wWinMain( HINSTANCE, HINSTANCE, LPWSTR, int )
{
	_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); 
#ifdef _DEBUG
 
	CPickSystem::UnitTest();
	CTextTexture::UnitTest();
	CRenderToTexture::UnitTest();
	CSceneManager::UnitTest();
 	CInput::UnitTest();
	C3DLineManager::UnitTest();
	ICamera::UnitTest();
	CSoundSystem::UnitTest();
	Demo * pGame=new Demo;
	Singleton<CGame>::Instance()->RunTest(800,600,pGame,pGame);
	delete pGame;
	return 0;
#endif // _DEBUG
 
	return 0;

}